import java.util.Scanner;

public class Demo11 {
    public static void main(String[] args) {
        System.out.println(getAvg());
    }

    public static int getAvg() {
        int[] grade = getGrade();
        int max = getArrayMax(grade);
        int min = getArrayMin(grade);
        int sum = getArraySum(grade);
        return (sum - max - min) / 4;
    }

    public static int[] getGrade() {
        int[] grade = new int[6];
        for (int i = 0; i < 6; i++) {
            System.out.println("请输入第" + (i + 1) + "个数字");
            grade[i] = getNumByScannerBetween1To100();
        }
        return grade;
    }

    /**
     * 键盘录入一个1到100的数字并返回.
     *
     * @return 键盘录入一个1到100的数字并返回.
     */
    public static int getNumByScannerBetween1To100() {
        Scanner sc = new Scanner(System.in);
        int grade = 0;
        try {
            while (true) {
                grade = Integer.parseInt(sc.nextLine());
                if (grade > 100 || grade < 0)
                    System.out.println("输入不合法重新输入！");
                else
                    break;
            }
        } catch (Exception e) {
            System.out.println("程序出错：" + e.getMessage());
        }
        return grade;
    }

    /**
     * 接收一个int类型的数组变量,获取数组最小值, 并返回.
     *
     * @param arr int类型的数组变量.
     * @return 返回数组种的最小值.
     */
    public static int getArrayMin(int[] arr) {
        if (arr == null)
            return -1;
        int Min = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (Min > arr[i])
                Min = arr[i];
        }
        return Min;
    }

    /**
     * 接收一个int类型的数组变量,获取数组最大值, 并返回.
     *
     * @param arr int类型的数组变量.
     * @return 返回数组种的最大值.
     */
    public static int getArrayMax(int[] arr) {
        if (arr == null)
            return -1;
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if (max < arr[i])
                max = arr[i];
        }
        return max;
    }

    /**
     * 接收一个int类型的数组变量,求和, 并返回.
     *
     * @param arr
     * @return
     */
    public static int getArraySum(int[] arr) {
        if (arr == null)
            return -1;
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum += arr[i];
        }
        return sum;
    }
}